/**
 * @file
 * @author
 * @date
 * @brief
 */

#ifndef __BOARD_R911_V1_1_H__
#define __BOARD_R911_V1_1_H__

#if defined(R911_V1_1_BOARD) || defined(R911_V1_11_BOARD)|| defined(Z1_V1_11_BOARD)||defined(R911M_V1_11_BOARD) || defined(R911M2_V1_11_BOARD)
typedef enum __boart_pin_map_t
{
    CHARGING_PLUGIN_PIN = 3,
    CHARGING_FULL_PIN = 4,
    GSENSOR_INT_PIN = 8,
    GSENSOR_CLOCK_PIN = 9,
    GSENSOR_DATA_PIN = 10,
    FLASH_CLOCK_PIN = 11,
    FLASH_MISO_PIN = 13, //?  SPI_MISO
    FLASH_MOSI_PIN = 12, //? SPI_MOSI
    FLASH_CS_PIN = 14,
    OLED_POWER_PIN = 15, //!<屏幕+触摸，常开
    OLED_DC_PIN = 16,
    OLED_CLOCK_PIN = 17,
    OLED_CS_PIN = 18,
    OLED_DATA_PIN = 19,
    TOUCHPAD_RESET_PIN = 20,
    TOUCHPAD_INT_PIN = 21,
    MOTOR_PIN = 22,
    PCBA_TEST_DATA_PIN = 23,
    PCBA_TEST_CLOCK_PIN = 24,
    TOUCHPAD_DATA_PIN = 25,
  	TOUCHPAD_CLOCK_PIN = 26,
    BUTTON_TOP_PIN = 27, // TOP
    BUTTON_PIN_NUM_1 = BUTTON_TOP_PIN,
    BUTTON_MIDDLE_PIN = 28, // MIDDLE
    BUTTON_PIN_NUM_2 = BUTTON_MIDDLE_PIN,
    BUTTON_BOTTOM_PIN = 29, // BOTTOM
    BUTTON_PIN_NUM_3 = BUTTON_BOTTOM_PIN,

    HEART_RATE_CLOCK_PIN = 30,
    TWI_DEVICE_CLOCK = HEART_RATE_CLOCK_PIN,
    HEART_RATE_DATA_PIN = 31,
    TWI_DEVICE_DATA = HEART_RATE_DATA_PIN,
} boart_pin_map_t;
#define G_I2C_CLK GSENSOR_CLOCK_PIN
#define G_I2C_DAT GSENSOR_DATA_PIN

#define SPI_OPERATING_FREQUENCY (0x02000000UL << (uint32_t)Freq_8Mbps) /*!< Slave clock frequency. */
#define TIMEOUT_COUNTER 0x3000UL                                       /*!< timeout for getting rx bytes from slave */

#define FLASH_SPIX (NRF_SPI0)
#define OLED_SPIX (NRF_SPI1)
#define OLED_SPIXM (NRF_SPIM1)

#define BUTTON_1_ACTIVE_STATE APP_BUTTON_ACTIVE_LOW
#define BUTTON_1_PULL_CFG NRF_GPIO_PIN_PULLUP

#define BUTTON_2_ACTIVE_STATE APP_BUTTON_ACTIVE_LOW
#define BUTTON_2_PULL_CFG NRF_GPIO_PIN_PULLUP

#define BUTTON_3_ACTIVE_STATE APP_BUTTON_ACTIVE_LOW
#define BUTTON_3_PULL_CFG NRF_GPIO_PIN_PULLUP

// Low frequency clock source to be used by the SoftDevice
#define NRF_CLOCK_LFCLKSRC                                                                                                                                                                             \
    {                                                                                                                                                                                                  \
        .source = NRF_CLOCK_LF_SRC_XTAL, .rc_ctiv = 0, .rc_temp_ctiv = 0, .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM                                                                           \
    }

// bootloader使用按键
#define BOOTLOADER_USE_BUTTON_PIN (BUTTON_MIDDLE_PIN)
#define BOOTLOADER_USE_BUTTON_PIN_PULL (BUTTON_2_PULL_CFG)
#define BOOTLOADER_USE_BUTTON_PIN_SENSE (BUTTON_2_ACTIVE_STATE)
#else
#error not R911_BOARD_V1_1
#endif
#endif
